From 650061e19522b6cacb34786bc34f1dcfabaf2da0 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Wed, 13 Jul 2005 12:58:41 +0000 Subject: [PATCH] Enable NX/XD feature for 32-bit PAE Xen. Signed-off-by: Keir Fraser --- xen/arch/x86/boot/x86_32.S | 23 +++++++++++++++++++++-- xen/arch/x86/boot/x86_64.S | 4 ++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/boot/x86_32.S b/xen/arch/x86/boot/x86_32.S index dc1df01e2a..fafc707bea 100644 --- a/xen/arch/x86/boot/x86_32.S +++ b/xen/arch/x86/boot/x86_32.S @@ -2,6 +2,7 @@ #include #include #include +#include #define SECONDARY_CPU_FLAG 0xA5A5A5A5 @@ -57,13 +58,13 @@ __start: /* Set up FPU. */ fninit - + /* Set up CR4, except global flag which Intel requires should be */ /* left until after paging is enabled (IA32 Manual Vol. 3, Sec. 2.5) */ mov mmu_cr4_features-__PAGE_OFFSET,%ecx and $0x7f,%cl # CR4.PGE (global enable) mov %ecx,%cr4 - + cmp $(SECONDARY_CPU_FLAG),%ebx je start_paging @@ -125,6 +126,24 @@ __start: loop 1b start_paging: +#ifdef CONFIG_X86_PAE + /* Enable Execute-Disable (NX/XD) support if it is available. */ + push %ebx + mov $0x80000000,%eax + cpuid + cmp $0x80000000,%eax /* Any function > 0x80000000? */ + jbe no_execute_disable + mov $0x80000001,%eax + cpuid + bt $20,%edx /* Execute Disable? */ + jnc no_execute_disable + movl $MSR_EFER,%ecx + rdmsr + bts $_EFER_NX,%eax + wrmsr +no_execute_disable: + pop %ebx +#endif mov $idle_pg_table-__PAGE_OFFSET,%eax mov %eax,%cr3 mov $0x80050033,%eax /* hi-to-lo: PG,AM,WP,NE,ET,MP,PE */ diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index c5a92e6627..85c599f536 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -63,7 +63,7 @@ __start: /* Check for Multiboot bootloader */ cmp $0x2BADB002,%eax jne not_multiboot - + /* Save the Multiboot info structure for later use. */ mov %ebx,0x100300 # multiboot_ptr @@ -91,7 +91,7 @@ skip_boot_checks: mov %eax,%cr3 /* Set up EFER (Extended Feature Enable Register). */ - movl $MSR_EFER, %ecx + movl $MSR_EFER,%ecx rdmsr btsl $_EFER_LME,%eax /* Long Mode */ btsl $_EFER_SCE,%eax /* SYSCALL/SYSRET */ -- 2.30.2